<?php

namespace App\Http\Controllers\Agency;

use App\Http\Controllers\Controller;
use App\Services\FollowService;
use hg\apidoc\annotation as Apidoc;
use Illuminate\Http\Request;

/**
 * 跟进模板管理
 * @Apidoc\Group("crm")
 */
class FollowController extends Controller
{
    /**
     * @Apidoc\Title ("跟进模板管理-模板列表")
     * @Apidoc\Url("/agency/followTemplate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=true,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=true,desc="每页条数")
     * @Apidoc\Returned("id",type="int",desc="模板ID")
     * @Apidoc\Returned("type",type="int",require=true,desc="模板类目1销售2服务")
     * @Apidoc\Returned("title",type="string",desc="模板标题")
     * @Apidoc\Returned("text",type="string",desc="模板内容")
     * @Apidoc\Returned("created_at",type="string",desc="模板创建时间")
     *
     */
    public function followTemplate(Request $request , FollowService $followService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $followService->followTemplate($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("跟进模板管理-模板添加")
     * @Apidoc\Url("/agency/followTemplateInsert")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("type",type="int",require=true,desc="模板类目1销售2服务")
     * @Apidoc\Param("title",type="string",require=true,desc="模板标题")
     * @Apidoc\Param("text",type="string",require=true,desc="模板内容")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function followTemplateInsert(Request $request , FollowService $followService)
    {
        $params = $request->input();
        $params['aid'] = $this->getAid();
        $result = $followService->followTemplateInsert($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError("添加失败，请重试！");
    }

    /**
     * @Apidoc\Title ("跟进模板管理-模板编辑")
     * @Apidoc\Url("/agency/followTemplateUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="模板id")
     * @Apidoc\Param("type",type="int",require=true,desc="模板类目1销售2服务")
     * @Apidoc\Param("title",type="string",require=true,desc="模板标题")
     * @Apidoc\Param("text",type="string",require=true,desc="模板内容")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function followTemplateUpdate(Request $request , FollowService $followService)
    {
        $params = $request->input();
        $result = $followService->followTemplateUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }

    /**
     * @Apidoc\Title ("跟进模板管理-模板删除")
     * @Apidoc\Url("/agency/followTemplateDel")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("id",type="int",require=true,desc="模板id")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function followTemplateDel(Request $request , FollowService $followService)
    {
        $params = $request->input();
        $result = $followService->followTemplateDel($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }


}
